package com.splic.product.service.impl;

import java.util.Date;
import java.util.List;
import com.splic.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.splic.product.mapper.UserBloodpressureDataMapper;
import com.splic.product.domain.UserBloodpressureData;
import com.splic.product.service.UserBloodpressureDataService;
import org.springframework.transaction.annotation.Transactional;

/**
 * 用户血压数据Service业务层处理
 * 
 * @author singe
 * @date 2022-01-04
 */
@Service
public class UserBloodpressureDataServiceImpl implements UserBloodpressureDataService
{
    @Autowired
    private UserBloodpressureDataMapper userBloodpressureDataMapper;

    /**
     * 查询用户血压数据
     * 
     * @param id 用户血压数据主键
     * @return 用户血压数据
     */
    @Override
    public UserBloodpressureData selectUserBloodpressureDataById(Long id)
    {
        return userBloodpressureDataMapper.selectUserBloodpressureDataById(id);
    }

    /**
     * 查询用户血压数据列表
     * 
     * @param userBloodpressureData 用户血压数据
     * @return 用户血压数据
     */
    @Override
    public List<UserBloodpressureData> selectPageList(UserBloodpressureData userBloodpressureData)
    {
        return userBloodpressureDataMapper.selectUserBloodpressureDataList(userBloodpressureData);
    }

    /**
     * 查询用户血压数据列表
     *
     * @param userBloodpressureData 用户血压数据
     * @return 用户血压数据
     */
    @Override
    public List<UserBloodpressureData> selectUserBloodpressureDataList(UserBloodpressureData userBloodpressureData)
    {
        return userBloodpressureDataMapper.selectUserBloodpressureDataList(userBloodpressureData);
    }

    /**
     * 新增用户血压数据
     * 
     * @param userBloodpressureData 用户血压数据
     * @return 结果
     */
    @Override
    public int insert(UserBloodpressureData userBloodpressureData)
    {
        userBloodpressureData.setCreateTime(DateUtils.getNowDate());
        return userBloodpressureDataMapper.insert(userBloodpressureData);
    }

    /**
     * 修改用户血压数据
     * 
     * @param userBloodpressureData 用户血压数据
     * @return 结果
     */
    @Override
    public int update(UserBloodpressureData userBloodpressureData)
    {
        userBloodpressureData.setUpdateTime(DateUtils.getNowDate());
        return userBloodpressureDataMapper.update(userBloodpressureData);
    }


    /**
     * 删除用户血压数据信息
     * 
     * @param id 用户血压数据主键
     * @return 结果
     */
    @Override
    public int deleteById(Long id)
    {
        return userBloodpressureDataMapper.deleteById(id);
    }
    /**
     * 修改用户血压数据
     *
     * @param userBloodpressureData 用户血压数据信息
     * @return 结果
     */
    @Override
    @Transactional
    public int saveOrUpdate(UserBloodpressureData userBloodpressureData)
    {
        if(userBloodpressureData.getId() != null){
            userBloodpressureData.setUpdateTime(new Date());
            return userBloodpressureDataMapper.update(userBloodpressureData);
        }else{
            userBloodpressureData.setCreateTime(new Date());
            return userBloodpressureDataMapper.insert(userBloodpressureData);
        }
    }
}
